#include "StdAfx.h"
#include "audiodef.h"
#include <mmsystem.h>
#include <mmreg.h>

WAVEFORMATEX tblWaveFormat[] = 
{
 	// wFormatTag, nChannels, nSamplesPerSec, mAvgBytesPerSec,
	// nBlockAlign, wBitsPerSample, cbSize
	// 8BIT
	{ WAVE_FORMAT_PCM, 1, 8000, 8000, 1, 8, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_PCM, 2, 8000, 16000, 2, 8, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_PCM, 1, 11025, 11025, 1, 8, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_PCM, 2, 11025, 22050, 2, 8, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_PCM, 1, 22050, 22050, 1, 8, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_PCM, 2, 22050, 44100, 2, 8, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_PCM, 1, 44100, 44100, 1, 8, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_PCM, 2, 44100, 88200, 2, 8, 0 },	// 44KHZ STEREO
	// 16BIT
	{ WAVE_FORMAT_PCM, 1, 8000, 16000, 2, 16, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_PCM, 2, 8000, 32000, 4, 16, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_PCM, 1, 11025, 22050, 2, 16, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_PCM, 2, 11025, 44100, 4, 16, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_PCM, 1, 22050, 44100, 2, 16, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_PCM, 2, 22050, 88200, 4, 16, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_PCM, 1, 44100, 88200, 2, 16, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0 },	// 44KHZ STEREO
	// 8BIT
	{ WAVE_FORMAT_ADPCM, 1, 8000, 8000, 1, 8, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_ADPCM, 2, 8000, 16000, 2, 8, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_ADPCM, 1, 11025, 11025, 1, 8, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_ADPCM, 2, 11025, 22050, 2, 8, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_ADPCM, 1, 22050, 22050, 1, 8, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_ADPCM, 2, 22050, 44100, 2, 8, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_ADPCM, 1, 44100, 44100, 1, 8, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_ADPCM, 2, 44100, 88200, 2, 8, 0 },	// 44KHZ STEREO
	// 16BIT
	{ WAVE_FORMAT_ADPCM, 1, 8000, 16000, 2, 16, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_ADPCM, 2, 8000, 32000, 4, 16, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_ADPCM, 1, 11025, 22050, 2, 16, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_ADPCM, 2, 11025, 44100, 4, 16, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_ADPCM, 1, 22050, 44100, 2, 16, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_ADPCM, 2, 22050, 88200, 4, 16, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_ADPCM, 1, 44100, 88200, 2, 16, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_ADPCM, 2, 44100, 176400, 4, 16, 0 },	// 44KHZ STEREO

	// 8BIT
	{ WAVE_FORMAT_G723_ADPCM, 1, 8000, 8000, 1, 8, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_G723_ADPCM, 2, 8000, 16000, 2, 8, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_G723_ADPCM, 1, 11025, 11025, 1, 8, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_G723_ADPCM, 2, 11025, 22050, 2, 8, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_G723_ADPCM, 1, 22050, 22050, 1, 8, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_G723_ADPCM, 2, 22050, 44100, 2, 8, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_G723_ADPCM, 1, 44100, 44100, 1, 8, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_G723_ADPCM, 2, 44100, 88200, 2, 8, 0 },	// 44KHZ STEREO
	// 16BIT
	{ WAVE_FORMAT_G723_ADPCM, 1, 8000, 16000, 2, 16, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_G723_ADPCM, 2, 8000, 32000, 4, 16, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_G723_ADPCM, 1, 11025, 22050, 2, 16, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_G723_ADPCM, 2, 11025, 44100, 4, 16, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_G723_ADPCM, 1, 22050, 44100, 2, 16, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_G723_ADPCM, 2, 22050, 88200, 4, 16, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_G723_ADPCM, 1, 44100, 88200, 2, 16, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_G723_ADPCM, 2, 44100, 176400, 4, 16, 0 },	// 44KHZ STEREO
	// 8BIT
	{ WAVE_FORMAT_MULAW, 1, 8000, 8000, 1, 8, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_MULAW, 2, 8000, 16000, 2, 8, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_MULAW, 1, 11025, 11025, 1, 8, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_MULAW, 2, 11025, 22050, 2, 8, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_MULAW, 1, 22050, 22050, 1, 8, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_MULAW, 2, 22050, 44100, 2, 8, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_MULAW, 1, 44100, 44100, 1, 8, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_MULAW, 2, 44100, 88200, 2, 8, 0 },	// 44KHZ STEREO
	// 16BIT
	{ WAVE_FORMAT_MULAW, 1, 8000, 16000, 2, 16, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_MULAW, 2, 8000, 32000, 4, 16, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_MULAW, 1, 11025, 22050, 2, 16, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_MULAW, 2, 11025, 44100, 4, 16, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_MULAW, 1, 22050, 44100, 2, 16, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_MULAW, 2, 22050, 88200, 4, 16, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_MULAW, 1, 44100, 88200, 2, 16, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_MULAW, 2, 44100, 176400, 4, 16, 0 },	// 44KHZ STEREO
	// 8BIT
	{ WAVE_FORMAT_ALAW, 1, 8000, 8000, 1, 8, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_ALAW, 2, 8000, 16000, 2, 8, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_ALAW, 1, 11025, 11025, 1, 8, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_ALAW, 2, 11025, 22050, 2, 8, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_ALAW, 1, 22050, 22050, 1, 8, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_ALAW, 1, 44100, 44100, 1, 8, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_ALAW, 2, 44100, 88200, 2, 8, 0 },	// 44KHZ STEREO
	// 16BIT
	{ WAVE_FORMAT_ALAW, 1, 8000, 16000, 2, 16, 0 },		// 8KHZ MONO
	{ WAVE_FORMAT_ALAW, 2, 8000, 32000, 4, 16, 0 },		// 8KHZ STEREO
	{ WAVE_FORMAT_ALAW, 1, 11025, 22050, 2, 16, 0 },		// 11KHZ MONO
	{ WAVE_FORMAT_ALAW, 2, 11025, 44100, 4, 16, 0 },		// 11KHZ STEREO
	{ WAVE_FORMAT_ALAW, 1, 22050, 44100, 2, 16, 0 },		// 22KHZ MONO
	{ WAVE_FORMAT_ALAW, 2, 22050, 88200, 4, 16, 0 },		// 22KHZ STEREO
	{ WAVE_FORMAT_ALAW, 1, 44100, 88200, 2, 16, 0 },		// 44KHZ MONO
	{ WAVE_FORMAT_ALAW, 2, 44100, 176400, 4, 16, 0 },	// 44KHZ STEREO

};

char tblAudioCodec[][32] = 
{
	"PCM",
	"ADPCM",
	"G723",
	"EVENT",
	"G711muLaw",
	"G711aLaw",
	"UNKNOWN"
};

char tblAudioSample[][32] = 
{
	"PCM_8BIT_8KHZ_MONO",
	"PCM_8BIT_8KHZ_STEREO",
	"PCM_8BIT_11KHZ_MONO",
	"PCM_8BIT_11KHZ_STEREO",
	"PCM_8BIT_22KHZ_MONO",
	"PCM_8BIT_22KHZ_STEREO",
	"PCM_8BIT_44KHZ_MONO",
	"PCM_8BIT_44KHZ_STEREO",
	"PCM_16BIT_8KHZ_MONO",
	"PCM_16BIT_8KHZ_STEREO",
	"PCM_16BIT_11KHZ_MONO",
	"PCM_16BIT_11KHZ_STEREO",
	"PCM_16BIT_22KHZ_MONO",
	"PCM_16BIT_22KHZ_STEREO",
	"PCM_16BIT_44KHZ_MONO",
	"PCM_16BIT_44KHZ_STEREO",
	"ADPCM_8BIT_8KHZ_MONO",
	"ADPCM_8BIT_8KHZ_STEREO",
	"ADPCM_8BIT_11KHZ_MONO",
	"ADPCM_8BIT_11KHZ_STEREO",
	"ADPCM_8BIT_22KHZ_MONO",
	"ADPCM_8BIT_22KHZ_STEREO",
	"ADPCM_8BIT_44KHZ_MONO",
	"ADPCM_8BIT_44KHZ_STEREO",
	"ADPCM_16BIT_8KHZ_MONO",
	"ADPCM_16BIT_8KHZ_STEREO",
	"ADPCM_16BIT_11KHZ_MONO",
	"ADPCM_16BIT_11KHZ_STEREO",
	"ADPCM_16BIT_22KHZ_MONO",
	"ADPCM_16BIT_22KHZ_STEREO",
	"ADPCM_16BIT_44KHZ_MONO",
	"ADPCM_16BIT_44KHZ_STEREO",
	"G723_8BIT_8KHZ_MONO",
	"G723_8BIT_8KHZ_STEREO",
	"G723_8BIT_11KHZ_MONO",
	"G723_8BIT_11KHZ_STEREO",
	"G723_8BIT_22KHZ_MONO",
	"G723_8BIT_22KHZ_STEREO",
	"G723_8BIT_44KHZ_MONO",
	"G723_8BIT_44KHZ_STEREO",
	"G723_16BIT_8KHZ_MONO",
	"G723_16BIT_8KHZ_STEREO",
	"G723_16BIT_11KHZ_MONO",
	"G723_16BIT_11KHZ_STEREO",
	"G723_16BIT_22KHZ_MONO",
	"G723_16BIT_22KHZ_STEREO",
	"G723_16BIT_44KHZ_MONO",
	"G723_16BIT_44KHZ_STEREO",
	"MULAW_8BIT_8KHZ_MONO",
	"MULAW_8BIT_8KHZ_STEREO",
	"MULAW_8BIT_11KHZ_MONO",
	"MULAW_8BIT_11KHZ_STEREO",
	"MULAW_8BIT_22KHZ_MONO",
	"MULAW_8BIT_22KHZ_STEREO",
	"MULAW_8BIT_44KHZ_MONO",
	"MULAW_8BIT_44KHZ_STEREO",
	"MULAW_16BIT_8KHZ_MONO",
	"MULAW_16BIT_8KHZ_STEREO",
	"MULAW_16BIT_11KHZ_MONO",
	"MULAW_16BIT_11KHZ_STEREO",
	"MULAW_16BIT_22KHZ_MONO",
	"MULAW_16BIT_22KHZ_STEREO",
	"MULAW_16BIT_44KHZ_MONO",
	"MULAW_16BIT_44KHZ_STEREO",
	"ALAW_8BIT_8KHZ_MONO",
	"ALAW_8BIT_8KHZ_STEREO",
	"ALAW_8BIT_11KHZ_MONO",
	"ALAW_8BIT_11KHZ_STEREO",
	"ALAW_8BIT_22KHZ_MONO",
	"ALAW_8BIT_22KHZ_STEREO",
	"ALAW_8BIT_44KHZ_MONO",
	"ALAW_8BIT_44KHZ_STEREO",
	"ALAW_16BIT_8KHZ_MONO",
	"ALAW_16BIT_8KHZ_STEREO",
	"ALAW_16BIT_11KHZ_MONO",
	"ALAW_16BIT_11KHZ_STEREO",
	"ALAW_16BIT_22KHZ_MONO",
	"ALAW_16BIT_22KHZ_STEREO",
	"ALAW_16BIT_44KHZ_MONO",
	"ALAW_16BIT_44KHZ_STEREO",
	"UNKNOWN",
};